﻿//MIT License
//Copyright (c) 2024 nuaazgg, Nanjing University of Aeronautics and Astronautics(NUAA)

using ExchangeSerialization;
using FlatBuffers;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using UnityEngine;
using WebSocketSharp;
using WebSocketSharp.Server;
public class DataTrans : WebSocketBehavior
{
    public HandJointData dataReaded;
    public bool isUpdated;
    private ConcurrentQueue<byte[]> incoming_messages;

    public DataTrans()
    : this(null)
    {
    }
    public DataTrans(ConcurrentQueue<byte[]> que)
    {
        incoming_messages = que;

    }

    protected override void OnMessage(MessageEventArgs e)
    {
        if (e.IsBinary)
        {
            incoming_messages.Enqueue(e.RawData);
        }

    }

    protected override void OnOpen()
    {
        base.OnOpen();
        Debug.Log("Connected");
    }

}
